package com.feihong.yw189.paidan.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.feihong.yw189.paidan.fragment.paidan.AllOrderList;
import com.feihong.yw189.paidan.fragment.paidan.BaseOrderList;
import com.feihong.yw189.paidan.fragment.paidan.CancleOrderList;
import com.feihong.yw189.paidan.fragment.paidan.FinishOrderList;

import java.util.ArrayList;
import java.util.HashMap;

public class PaiDanOrderAdapter extends FragmentPagerAdapter {

    private HashMap<String, String> numMap = new HashMap<>();
    public ArrayList<BaseOrderList> fragments;

    public PaiDanOrderAdapter(FragmentManager fm) {
        super(fm);
        fragments = new ArrayList<>();

        AllOrderList allOrderListFragment = AllOrderList.newInstance(AllOrderList.class.getName());
        FinishOrderList finishOrderListFragment = FinishOrderList.newInstance(FinishOrderList.class.getName());
        CancleOrderList cancleOrderListFragment = CancleOrderList.newInstance(CancleOrderList.class.getName());


        fragments.add(allOrderListFragment);
        fragments.add(finishOrderListFragment);
        fragments.add(cancleOrderListFragment);

    }

    public void setData(HashMap<String, String> numMap) {
        this.numMap = numMap;
        notifyDataSetChanged();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return numMap.get("" + position);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
